package cn.funeralobjects.aoss.converter;

import cn.funeralobjects.aoss.enums.RedundancyType;

import javax.persistence.AttributeConverter;

/**
 * Converter of RedundancyType
 *
 * @author FuneralObjects
 * Create date: 2020/6/1 11:54 AM
 */
public class RedundancyTypeConverter implements AttributeConverter<RedundancyType, String> {
    @Override
    public String convertToDatabaseColumn(RedundancyType attribute) {
        return attribute == null ? null : attribute.name();
    }

    @Override
    public RedundancyType convertToEntityAttribute(String dbData) {
        return dbData == null ? null : RedundancyType.valueOf(dbData);
    }
}
